<?php

use think\facade\Route;

// 订单 路由
Route::group('order', function () {
    // 订单类型
    Route::get('order/getType', 'admin.order.Order/getType');

    // 售后类型
    Route::get('aftersale/getType', 'admin.order.Aftersale/getType');

    Route::group(function () {
        // 订单管理
        Route::get('order/export', 'admin.order.Order/export');
        Route::get('order/exportDelivery', 'admin.order.Order/exportDelivery');
        Route::get('order/action/:id', 'admin.order.Order/action');
        Route::get('order/updateExpress/:order_express_id', 'admin.order.Order/updateExpress');
        Route::put('order/applyRefundRefuse/:id', 'admin.order.Order/applyRefundRefuse');
        Route::put('order/changeFee/:id', 'admin.order.Order/changeFee');
        Route::put('order/editConsignee/:id', 'admin.order.Order/editConsignee');
        Route::put('order/editMemo/:id', 'admin.order.Order/editMemo');
        Route::put('order/fullRefund/:id', 'admin.order.Order/fullRefund');
        Route::put('order/refund/:id/:item_id', 'admin.order.Order/refund');
        Route::resource('order', 'admin.order.Order');
        // 发货
        Route::post('order/dispatch', 'admin.order.Order/dispatch');
        Route::post('order/customDispatch', 'admin.order.Order/customDispatch');

        // 收货，拒收
        Route::post('order/offlineConfirm/:id', 'admin.order.Order/offlineConfirm');
        Route::post('order/offlineRefuse/:id', 'admin.order.Order/offlineRefuse');

        // 售后单管理
        Route::put('aftersale/completed/:id', 'admin.order.Aftersale/completed');
        Route::put('aftersale/refuse/:id', 'admin.order.Aftersale/refuse');
        Route::put('aftersale/refund/:id', 'admin.order.Aftersale/refund');
        Route::put('aftersale/addLog/:id', 'admin.order.Aftersale/addLog');
        Route::resource('aftersale', 'admin.order.Aftersale');

        // 订单发票
        Route::get('invoice', 'admin.order.Invoice/list')->name('admin.order.Invoice.list');
        Route::put('invoice/confirm/:id', 'admin.order.Invoice/confirm')->name('admin.order.Invoice.confirm');
    })->middleware('check_rule', 'admin');
});


// 交易订单路由
Route::group('trade/order', function () {
    // 获取交易订单类型
    Route::get('getType', 'admin.trade.Order/getType');

    Route::group(function () {
        // 交易订单
        Route::get('export', 'admin.trade.Order/export');
        Route::resource('', 'admin.trade.Order');
    })->middleware('check_rule', 'admin');
});